﻿using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Drawing;
using System.Data;
using System.Linq;
using System.Text;
using System.Windows.Forms;
using PolePosition.v3.GoogleEarth;

namespace PolePosition.v3.Desktop.Utility
{
    public partial class TabMap : UserControl
    {
        public TabMap()
        {
            InitializeComponent();
            m_Map = new MapDisplay(mapControl1);
        }
        private MapDisplay m_Map;
        [Browsable(false), DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)]
        public MapDisplay Map 
        {
            get { return m_Map; }
        }

        public class MapDisplay
        {
            MapControl m_MapControl;
            public MapDisplay(MapControl mapControl)
            {
                m_MapControl = mapControl;
            }

            public Common.Enumerations.DataTypes KMLType { get; set; }

            public void LoadKmlFromFile(Common.Enumerations.DataTypes kmlType, string path)
            {
                Program.FormMain.ShowMapTab();
                KMLType = kmlType;
                m_MapControl.LoadKmlFromFile(path);
            }

            /// <summary>
            /// Load a KML to the map; KML with the same NAME will be replaced
            /// </summary>
            /// <param name="kml"></param>
            public void LoadKmlFromString(Common.Enumerations.DataTypes kmlType, string kml)
            {
                Program.FormMain.ShowMapTab();
                KMLType = kmlType;
                m_MapControl.LoadKmlFromString(kml);
            }

        }
    }
}
